Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): handle fieldset members in FormInput #7045

Merged
merged 4 commits into from
Jul 1, 2024
Merged

Conversation

hermanwikner
Copy link
Member

@hermanwikner hermanwikner commented Jun 30, 2024

Description

This pull request fixes an issue where the FormInput would not render a field inside a fieldset. The current logic only finds fields that have the kind of "field" but does not handle the kind of "fieldSet". The issue can be reproduced by:

  1. Adding the following schema with an array field that has a fieldset defined:

    import {defineType} from 'sanity'
    
    export const myDocument = defineType({
      type: 'document',
      name: 'myDocument',
    
      fieldsets: [
        {
          name: 'fieldset',
          title: 'Fieldset',
        },
      ],
    
      fields: [
        {
          type: 'array',
          name: 'fieldsetArray',
          title: 'Fieldset array',
    
          fieldset: 'fieldset',
    
          of: [
            {
              type: 'object',
              name: 'myObject',
              fields: [
                {
                  name: 'string',
                  type: 'string',
                  title: 'String',
                },
              ],
            },
          ],
        },
      ],
    })
  2. Enabling the array tree editing beta feature:

    import {defineConfig} from 'sanity'
    
    export default defineConfig({
      // ...
    
      features: {
        beta: {
          treeArrayEditing: {
            enabled: true
          }
        }
      }
    })
  3. Creating an array item, and the FormInput will render this error message:

    Screenshot 2024-06-30 at 17 28 18

What to review

  • Ensure that the issue is fixed
  • General code review

Notes for release

N/A

Copy link

vercel bot commented Jun 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
page-building-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 1, 2024 10:12am
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 1, 2024 10:12am
test-compiled-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 1, 2024 10:12am
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 1, 2024 10:12am
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 1, 2024 10:12am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Jul 1, 2024 10:12am

Copy link
Contributor

No changes to documentation

Copy link
Contributor

github-actions bot commented Jun 30, 2024

Component Testing Report Updated Jul 1, 2024 10:20 AM (UTC)

File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 38s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 7s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 26s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 32s 11 7 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 15s 6 0 0
formBuilder/inputs/PortableText/DisableFocusAndUnset.spec.tsx ✅ Passed (Inspect) 9s 3 0 0
formBuilder/inputs/PortableText/DragAndDrop.spec.tsx ✅ Passed (Inspect) 44s 2 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 36s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 17s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 7s 18 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 7s 3 9 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 21s 9 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 16s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 1m 5s 21 0 0
formBuilder/tree-editing/TreeEditing.spec.tsx ✅ Passed (Inspect) 1m 5s 21 0 0

Copy link
Contributor

@RitaDias RitaDias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 Fantastic work! Do you mind adding a component test for this? 🙏

@hermanwikner hermanwikner requested review from a team and sjelfull and removed request for a team July 1, 2024 08:40
Copy link
Contributor

@RitaDias RitaDias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@hermanwikner hermanwikner added this pull request to the merge queue Jul 1, 2024
Merged via the queue into next with commit b932de6 Jul 1, 2024
44 checks passed
@hermanwikner hermanwikner deleted the edx-1547 branch July 1, 2024 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants